package com.rao.springbootschoolshop.config.home;


import com.rao.springbootschoolshop.constant.RunTimeConstant;
import com.rao.springbootschoolshop.interceptor.home.HomeGlobalInterceptor;
import com.rao.springbootschoolshop.interceptor.home.HomeLoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 注册配置拦截器的配置文件
 */
@Configuration
public class HomeWebConfig implements WebMvcConfigurer{

    @Autowired
    private HomeLoginInterceptor homeLoginInterceptor; //我们自定义的拦截器
    @Autowired
    private HomeGlobalInterceptor homeGlobalInterceptor; //拦截器

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(homeGlobalInterceptor).addPathPatterns("/**").excludePathPatterns(RunTimeConstant.HomeGlobaExcludePathPatterns);
        registry.addInterceptor(homeLoginInterceptor).addPathPatterns("/**").excludePathPatterns(RunTimeConstant.HomeLogineExcludePathPatterns);
    }
    }
